package cn.topevery.garden.dal.dao.impl;

import cn.topevery.garden.dal.dao.DingtalkAttendanceGroupsWorkDayRelationDao;
import cn.topevery.garden.entity.po.DingtalkAttendanceGroupsWorkDayRelation;
import cn.topevery.garden.entity.query.DingtalkAttendanceGroupsWorkDayRelationQuery;
import cn.topevery.garden.entity.vo.DingtalkAttendanceGroupsWorkDayRelationVO;
import cn.topevery.garden.framework.base.BaseDaoImpl;
import hw.topevery.framework.db.CommandType;
import hw.topevery.framework.db.entity.DataPager;
import hw.topevery.framework.db.entity.SqlQueryMate;
import hw.topevery.framework.db.enums.ScriptConditionEnum;
import hw.topevery.framework.entity.DbCsp;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 
 *
 * @author code-generate
 * @date 2021-09-02
 */
@Repository
public class DingtalkAttendanceGroupsWorkDayRelationDaoImpl extends BaseDaoImpl<DingtalkAttendanceGroupsWorkDayRelation> implements DingtalkAttendanceGroupsWorkDayRelationDao {
    @Override
    public <P extends DbCsp> List<DingtalkAttendanceGroupsWorkDayRelation> getSearch(P para) {
        return null;
    }

    

    @Override
    public DataPager<DingtalkAttendanceGroupsWorkDayRelationVO> listPage(DingtalkAttendanceGroupsWorkDayRelationQuery query) {
        String table = "t_dingtalk_attendance_groups_work_day_relation tdagwdr";

        String columns = "tdagwdr.*";

        int pageIndex = query.pageIndex - 1;
        int pageSize = query.pageSize;

        SqlQueryMate sqlQueryMate = new SqlQueryMate(table).setColumns(columns).setOrderBy("tdagwdr.c_id desc");
        sqlQueryMate
                .where(true, "tdagwdr.c_db_status", ScriptConditionEnum.Eq, 0)
        ;

        return getDataPager(sqlQueryMate, pageSize, pageIndex, DingtalkAttendanceGroupsWorkDayRelationVO.class);
    }

    @Override
    public void truncate() {
        String table = "t_dingtalk_attendance_groups_work_day_relation";
        String truncateSql="truncate table ";
        run(truncateSql+table, CommandType.Text, dbCmd -> {
            dbCmd.executeNonQuery();
        });
    }
}
